<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		
		<link rel="stylesheet"  href="../static/css/bootstrap.min.css"/>
		<script src="../static/js/jquery-3.4.1.min.js"></script>
		<script src="../static/js/bootstrap.min.js"></script>
		<style>
		  .fakeimg {
		      height: 200px;
		      background: #aaa;
		  }
		  </style>
		<title></title>
	</head>
	<body>
		<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
			  <span class="navbar-brand" href="#">文件管理</span>
			  <div class="collapse navbar-collapse" id="collapsibleNavbar">
			    <ul class="navbar-nav">
			      <li class="nav-item">
			        <a class="nav-link" href="index">文件上传</a>
			      </li>    
			    </ul>
			  </div>  
		</nav>
		
		
		<div class="container" style="margin-top:20px;">
			<div style="margin-top:20px;">
				<iframe id="ifActionResult" name="ifTmp" width="1px" height="1px" style="display: none;"></iframe>
				<form id="hiddenform" name="hiddenform" method="get" style="display:none" action="/file/download" target="ifTmp">
					<input type="text" name="uuidName" id="uuidName" />
				</form>
			</div>
			
			<table class="table table-hover" align="center" id="recordtable">
				 <tr>
					 <th>文件名</th>
					 <th>原始文件名</th>
					 <th>文件大小</th>
					 <th>文件类型</th>
					 <th>文件上传时间</th>
					 <th>操作</th>
				 </tr>
			</table>
		</div>
	</body>
	<script type="text/javascript"> 
		$(document).ready(function() {
			$.ajax({
			    url:'/file/findall',
			    type:'get',
			    data:'',
			    success:function(data){
			    	$.each(data,function(index,item){
					     var tr;
					     tr='<td id="uuidName">'+item.uuidName+'</td>'+'<td>'+item.fileName+'</td>'+'<td>'+item.fileSize+'</td>'+'<td>'+item.fileType+'</td>'+'<td>'+item.createDate+'</td>'+'<td><button id="download" class="btn btn-primary btn-sm" onclick="downloadfile(this)">下载文件</button></td>';
					     $("#recordtable").append('<tr>'+tr+'</tr>')
					   })
			 	}
			})
      	});
		
		function downloadfile(obj) {
			var x = $(obj).parent().parent().find("td");  
			var uuidName = x.eq(0).text()  
			console.log(uuidName);
	        $("#uuidName").val(uuidName);
			var form = $("#hiddenform");  
		    form.submit();
		}
		
	</script>
</html>
